// 判空
const isNotEmpty = (str) => {
    return str && str !== ''
}

// 校验手机号
const isValidPhoneNumber = (phoneNumber) => {
    const regex = /^1(3|4|5|6|7|8|9)\d{9}$/;
    return regex.test(phoneNumber);
}

// 校验电话号
const isValidTelephoneNumber = (telephoneNumber) => {
    const regex = /^(0)\d{2,3}-*\d{7}$/;
    return regex.test(telephoneNumber);
}

// 校验身份证号
const isValidIDCardNumber = (idCardNumber) => {
    const regex = /(^(1-9)\d{5}(18|19|((23)\d))\d{2}((0(1-9))|(10|11|12))(((0-2)(1-9))|10|20|30|31)\d{3}(0-9Xx)$)|(^(HM)(0-9){8}$)|(^((\s?(A-Za-z))|((A-Za-z){2}))\d{6}(\((0-9Aa)\)|(0-9Aa))$)|(^(1|5|7)(0-9){6}(\((0-9Aa)\)|(0-9Aa))$)/;
    return regex.test(idCardNumber);
}

// 校验邮箱
const isValidEmail = (email) => {
    const regex = /^\w+@(a-z0-9)+\.(a-z){2,6}$/;
    return regex.test(email);
}

export default {
    isValidEmail,
    isValidIDCardNumber,
    isValidTelephoneNumber,
    isValidPhoneNumber,
    isNotEmpty
}